﻿using EntityModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace EGS.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class SchoolForumController : ControllerBase
    {
        private readonly EGSDbContext db;
        public SchoolForumController(EGSDbContext context)
        {
            db = context;
        }

        //[HttpGet]
        //public List<EGS_School> GetBySelect([FromBody] string Message, string Emila,string LearningForum, string SchooolAnniversary,string Innovation) { }

        [HttpGet("{id}")]
        public EGS_SchoolForum? GetEGS_SchoolForumInfoById(Guid id)
        {
            EGS_SchoolForum? SchoolForum = new EGS_SchoolForum();
            SchoolForum = db.SchoolForum.Where(o => o.ID == id).FirstOrDefault();
            return SchoolForum;
        }
        [HttpPost]
        public Result AddSchoolForum([FromBody] EGS_SchoolForum SchoolForum)
        {
            Result result = new Result();
            db.SchoolForum.Add(SchoolForum);
            result.Data = db.SaveChanges();
            return result;
        }
        [HttpDelete]
        public Result DelSchool(Guid Id)
        {
            Result? result = new Result();
            EGS_SchoolForum? School = new EGS_SchoolForum();
            School = db.SchoolForum.Where(O => O.ID == Id).FirstOrDefault();
            return result;
        }
    }
}
